how to handle transaction in sql